
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css"/>
    <link rel="stylesheet" href="https://demo.easyweb.vip/iframe/assets/module/admin.css?v=318"/>
    <script type="text/javascript" src="/static/js/jquery-1.7.2.js"></script>
    <style>
        body .tox-tinymce-aux { z-index: 19892000; }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card" id="kid" th:attr="name=${knowledges.kid}">
        <div class="layui-card-body">
            <textarea id="demoEditor" th:attr="name=${knowledges.kmessage}"></textarea>
        </div>
        <div class="layui-form-item">
           <div class="layui-input-block text-center">
               <button ew-event="closeThisTabs" type="button" class="layui-btn layui-btn-primary" id="cloneDemoEdtInsertContent">&emsp;取消&emsp;</button>
               <button class="layui-btn" lay-filter="eQuestionSubmit" lay-submit id="eQuestionSubmit">&emsp;修改&emsp;</button>
           </div>
       </div><br><br>
    </div>
</div>
<!-- js部分 -->
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="https://demo.easyweb.vip/iframe/assets/js/common.js?v=318"></script>
<script type="text/javascript" src="https://demo.easyweb.vip/iframe/assets/libs/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
$(top.hangge());
</script>
<script>
    layui.use(['layer', 'admin', 'form', 'table','element'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var admin = layui.admin;
        var table = layui.table;
  	  	var form = layui.form;
  	  	var element = layui.element;
        var content = [
            '<div style="text-align: center;color: #fff;background-image: linear-gradient(to right,#009688,#5fb878);padding: 20px;">',
            '   <div style="font-size: 28px;margin-bottom: 10px;">EASY WEB 后台管理模板</div>',
            '   <div style="font-size: 18px">基于Layui的一套通用型后台管理模板，拥有众多原创组件及模板页面</div>',
            '</div><br/>'
        ].join('');
        initT();
        // 渲染富文本编辑器
        function initT(){
	        tinymce.init({
	            selector: '#demoEditor',
	            height: 690,
	            branding: false,
	            language: 'zh_CN',
	            plugins: 'code print preview fullscreen paste searchreplace save autosave link autolink image imagetools media table codesample lists advlist hr charmap emoticons anchor directionality pagebreak quickbars nonbreaking visualblocks visualchars wordcount',
	            toolbar: 'fullscreen preview code | undo redo | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | formatselect fontselect fontsizeselect | link image media emoticons charmap anchor pagebreak codesample | ltr rtl',
	            toolbar_drawer: 'sliding',
	            images_upload_url: '../../../json/tinymce-upload-ok.json',
	            file_picker_types: 'media',
	            file_picker_callback: function (callback, value, meta) {
	                layer.msg('演示环境不允许上传', {anim: 6});
	            },
	            init_instance_callback: function (editor) {
	                console.log(editor);
	            }
	        });
        }
        flush();
        function flush(){
        	setTimeout(function(){
        		tinymce.get('demoEditor').setContent($("#demoEditor").attr("name"));
        		$("#demoEditor").attr("name","");
			 },500);
        	
        }
        $('#eQuestionSubmit').click(function () {
       	 // 获取内容
         var content = tinymce.get('demoEditor').getContent()+'';
       	 if(content===''){
       		layer.msg("请输入内容！", {icon: 5});
    		return false;
       	 }
         let params = {};
         params.kmessage = content;
         params.id = $("#kid").attr("name");
         $.ajax( {
             url : '/admin/knowledge/modification', 
             type : 'post',
             data: params,
             dataType : 'json',
             success : function(data) {
            	 if(data.code==0){
            		 layer.msg(data.msg,{icon: 1});
            		 setTimeout(function () {
             		   		tinymce.get('demoEditor').setContent('', {});
                        	tinymce.get('demoEditor').remove();
               		 		var index = parent.layer.getFrameIndex(window.name);
            			 	parent.layer.close(index);
           		 	},1500);
	        	 }else{
	        		 layer.msg(data.msg,{icon: 2});
	        	 }
             }
         });
       });
       $('#cloneDemoEdtInsertContent').click(function () {
   		   	tinymce.get('demoEditor').setContent('', {});
            tinymce.get('demoEditor').remove();
     		var index = parent.layer.getFrameIndex(window.name);
  			parent.layer.close(index);
        });
    });
</script>
</body>
</html>